import { defineStore } from "pinia";
import { getHotSuggestions, getHomeCategories, getHomeSelected } from "@/servieces/index"

export const useHomeStore = defineStore("homeStore", {
  state: () => ({
    hotSuggestions: [],
    categories: [],
    currentPage: 1,
    selectedList: []
  }),
  actions: {
    async storeGetHotSuggestions() {
      const res = await getHotSuggestions()
      this.hotSuggestions = res.data
    },
    async storeGetHomeCategories() {
      const res = await getHomeCategories()
      this.categories = res.data
    },
    async storeGetHomeSelected() {
      const res = await getHomeSelected(this.currentPage)
      this.selectedList.push(...res.data)
      this.currentPage++
    }
  }
})